<template>
	<div class="searchBox_background"> 
		<div class="searchBox">
			<div class="search">
				<div class="searchDel"><span class="iconfont icon-Close-small" @click="searchDel"></span></div>
				<div class="searchTop">
					<input type="text" class="searchInput" v-model="word"  @keyup.enter="wordSel(word)"/>
					<span class="iconfont icon-search" @click="wordSel(word)"></span>
				</div>
				<div class="searchBottom">
					<div class="searchTitle">热搜词</div>
					<div class="hotwordBox">
						<span class="hotword" v-for="item in wordList" @click="wordSel(item.word)">{{ item.word }}</span>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
export default {
	props: ['sss'],
	data() {
		return {
			wordList: [],
			url: '',
			word: ''
		};
	},
	created() {
		this.url = window.location.href.split('frontjeecmsx2')[0];
	},
	mounted() {
		this.fetchSearchwordList();
	},
	methods: {
		searchDel() {
			this.$emit('searchDel', false);
		},
		fetchSearchwordList() {
			homeApi.fetchSearchwordList({ sortType: 1, limit: 20 }, res => {
				if (res.code == '00000 00000') {
					this.wordList = res.data;
				} else {
				}
			});
		},
		wordSel(word) {
			if(window.location.origin.includes('127')){
				window.location.href = this.url + 'frontjeecmsx2/src/page/searchPage.html?' + 'word=' + word;
			}else{
				window.location.href = window.location.origin + '/page-searchPage.html?' + 'word=' + word;
			}
			
		}
	}
};
</script>

<style>
.searchBox_background{
		background-color: rgba(0,0,0,0.5);
		position: absolute;
		top: 110px;
		z-index: 3;
		width: 100%;
		height: calc(100% - 110px);
		overflow: hidden;
}
.searchBox {
	z-index: 2;
	width: 100%;
	background: #fff;
	
}
.search {
	width: 1200px;
	margin: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	background-color: #fff;
}
.searchDel {
	margin-top: 24px;
	width: 100%;
	display: flex;
	justify-content: flex-end;
}
.searchDel .iconfont{
	font-size: 40px;
}
.icon-Close-small {
	width: 40px;
	height: 40px;
	font-size: 40px;
	line-height: 40px;
	color: #666;
	cursor: pointer;
}
.icon-Close-small:hover {
	color: #333;
}
.searchTop {
	display: flex;
	align-items: center;
	margin-top: 24px;
}
.searchTop .searchInput {
	padding: 0 16px;
	width: 785px;
	height: 44px;
	background: #ffffff;
	border-radius: 4px 0px 0px 4px;
	opacity: 1;
	outline-style: none;
	border: 1px solid #e0e0e0;
}
.searchTop .icon-search {
	display: inline-block;
	width: 24px;
	height: 24px;
	padding: 10px 16px;
	font-size: 24px;
	line-height: 24px;
	color: #fff;
	background: #ff3333;
	border-radius: 0px 4px 4px 0px;
	cursor: pointer;
}
.searchTop .icon-search:hover {
	opacity: 0.9;
}
.searchBottom {
	width: 841px;
	margin-top: 40px;
}
.searchBottom .searchTitle {
	height: 16px;
	font-size: 18px;
	font-family: PingFang SC-Regular, PingFang SC;
	font-weight: 400;
	color: #333333;
	line-height: 16px;
}
.searchBottom .hotwordBox {
	margin-top: 24px;
	padding-bottom: 102px;
}
.searchBottom .hotwordBox .hotword {
	display: inline-block;
	background: #f8f8f8;
	border-radius: 4px;
	height: 16px;
	font-size: 16px;
	font-family: PingFang SC-Regular, PingFang SC;
	font-weight: 400;
	color: #333333;
	line-height: 16px;
	padding: 12px 16px;
	margin-bottom: 16px;
	margin-right: 16px;
}
.searchBottom .hotwordBox .hotword:hover {
	background: #ff3333;
	color: #ffffff;
	cursor: pointer;
}
</style>
